package com.alasbusy.alasbusyapp.activity.twoactivity;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import com.alasbusy.alasbusyapp.R;
import com.alasbusy.alasbusyapp.activity.detail.MusicMoreActivity;
import com.alasbusy.alasbusyapp.adapter.OnTheWayAdapter;
import com.alasbusy.alasbusyapp.base.BaseActivity;
import com.alasbusy.alasbusyapp.bean.HomeBean;
import com.zhy.android.percent.support.PercentLinearLayout;

import java.util.ArrayList;
import java.util.List;

public class OnTheWayActivity extends BaseActivity implements View.OnClickListener {

    private RecyclerView ontheway_recycle;
    public List<HomeBean> list = new ArrayList<>();
    private OnTheWayAdapter onTheWayAdapter;
    private ImageView ontheway_music_img_01;
    private ImageView ontheway_music_img_02;
    private PercentLinearLayout ontheway_music_layout_01;
    private PercentLinearLayout ontheway_music_layout_02;

    @Override
    protected void initView() {
        PercentLinearLayout html_title = findViewById(R.id.ontheway_top_title);
        setTop(html_title);
        getVisibility(true, this);
        getTitle("在路上");

        ontheway_recycle = findViewById(R.id.ontheway_recycle);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        ontheway_recycle.setLayoutManager(linearLayoutManager);
        onTheWayAdapter = new OnTheWayAdapter(this);
        ontheway_recycle.setAdapter(onTheWayAdapter);

        ontheway_music_img_01 = findViewById(R.id.ontheway_music_img_01);
        ontheway_music_img_02 = findViewById(R.id.ontheway_music_img_02);

        ontheway_music_layout_01 = findViewById(R.id.ontheway_music_layout_01);
        ontheway_music_layout_02 = findViewById(R.id.ontheway_music_layout_02);
    }

    @Override
    protected void initData() {
        setData(0);
    }

    @Override
    protected void initListener() {
        findViewById(R.id.ontheway_video_btn_more).setOnClickListener(this);
        findViewById(R.id.ontheway_music_btn_more).setOnClickListener(this);
        findViewById(R.id.ontheway_img_btn_more).setOnClickListener(this);
        ontheway_music_img_01.setOnClickListener(this);
        ontheway_music_img_02.setOnClickListener(this);
        ontheway_music_layout_01.setOnClickListener(this);
        ontheway_music_layout_02.setOnClickListener(this);
    }

    @Override
    public int getLayout() {
        return R.layout.activity_on_the_way;
    }

    public void setData(int page) {
        list.clear();
        //获取本地数据库里的数据
        /*guestRegistration = GuestRegistrationManager.getInstance().getGuestRegistration(page);
        if (guestRegistration != null && guestRegistration.size() > 0) {
            visitorReservationAdapter.setList(guestRegistration);
            fragment_visitor_reser.setAdapter(visitorReservationAdapter);
            visitorReservationAdapter.changeMoreStatus(SystemDeleteUserAdapter.LOADING_NO);
            fragment_visitor_reser.setVisibility(View.VISIBLE);
            no_data.setVisibility(View.GONE);
        }else {
            fragment_visitor_reser.setVisibility(View.GONE);
            no_data.setVisibility(View.VISIBLE);
        }*/
        HomeBean homeBean = new HomeBean();
        HomeBean.DataBean dataBean = new HomeBean.DataBean();
        HomeBean.DataBean.ItemdataBean itemdataBean = new HomeBean.DataBean.ItemdataBean();
        itemdataBean.setTitle("万叶霜");
        itemdataBean.setContent("需求：easyUI应该都熟悉，就是点击左边菜单栏，上面出现tab标签和子页面，这个也类似，不过还需要一个功能，就是点");
        itemdataBean.setCount("59");
        itemdataBean.setName("kyc");
        itemdataBean.setTime("2018-5-11");
        dataBean.setItemdata(itemdataBean);
        homeBean.setData(dataBean);

        HomeBean homeBean1 = new HomeBean();
        HomeBean.DataBean dataBean1 = new HomeBean.DataBean();
        HomeBean.DataBean.ItemdataBean itemdataBean1 = new HomeBean.DataBean.ItemdataBean();
        itemdataBean1.setTitle("万叶霜");
        itemdataBean1.setContent("《CSS Secrets》是@Lea Verou最新著作，这本书讲解了有关于CSS中一些小秘密。是一本CSSer值得一读的一本书，经");
        itemdataBean1.setCount("95");
        itemdataBean1.setName("kyc");
        itemdataBean1.setTime("2018-5-11");
        dataBean1.setItemdata(itemdataBean1);
        homeBean1.setData(dataBean1);

        HomeBean homeBean2 = new HomeBean();
        HomeBean.DataBean dataBean2 = new HomeBean.DataBean();
        HomeBean.DataBean.ItemdataBean itemdataBean2 = new HomeBean.DataBean.ItemdataBean();
        itemdataBean2.setTitle("万叶霜");
        itemdataBean2.setContent("用jQuery写一个通过点击左右图标来翻阅图片的小插件，写好后测试可以正常运行，但是放到Tab中后发现只有第一个Tab");
        itemdataBean2.setCount("37");
        itemdataBean2.setName("kyc");
        itemdataBean2.setTime("2018-5-11");
        dataBean2.setItemdata(itemdataBean2);
        homeBean2.setData(dataBean2);

        list.add(homeBean);
        list.add(homeBean1);
        list.add(homeBean2);
        onTheWayAdapter.setList(list);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ontheway_img_btn_more:
                break;
            case R.id.ontheway_music_btn_more:
                startActivity(new Intent(OnTheWayActivity.this, MusicMoreActivity.class));
                break;
            case R.id.ontheway_video_btn_more:
                break;
            case R.id.ontheway_music_img_01:
            case R.id.ontheway_music_layout_01:

                break;
            case R.id.ontheway_music_img_02:
            case R.id.ontheway_music_layout_02:
                break;

        }
    }
}
